home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FILES.SWG / 0010_FILSHAR3.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  59 lines

  1. FileSHARinG !
  2.  
  3.  
  4. When sharing Files concurrently, by means of For example a multitasker or a
  5. network, it is necessary to use the File sharing as provided by the Dos
  6. command SHARE, or as provided by a Network shell (In Novell File sharing is
  7. supported by the network shell on Servers, not locally. Check your network
  8. documentation For more inFormation).
  9.  
  10. File sharing is simple in TP/BP, since the system Variable FileMode defines
  11. in what mode a certain File is opened in:
  12.  
  13. Const
  14.    fmReadOnly  = $00;  (* *)
  15.    fmWriteOnly = $01;  (* Only one of these should be used *)
  16.    fmReadWrite = $02;  (* *)
  17.  
  18.    fmDenyAll   = $10;  (* together With only one of these  *)
  19.    fmDenyWrite = $20;  (* *)
  20.    fmDenyRead  = $30;  (* *)
  21.    fmDenyNone  = $40;  (* *)
  22.  
  23.    fmNoInherit = $70;  (* Set For "No inheritance"         *)
  24.  
  25.  
  26. Construction the FileMode Variable is easy, just add the appropriate values:
  27.  
  28. FileMode:=fmReadOnly+fmDenyNone;
  29.       (Open File For reading only, allow read and Write.)
  30.  
  31. FileMode:=fmReadWrite+fmDenyWrite;
  32.       (Open File For both read and Write, deny Write.)
  33.  
  34. FileMode:=fmReadWrite+fmDenyAll;
  35.       (Open File For both read and Write, deny all.)
  36.  
  37. Say you open the File in "fmReadWrite+fmDenyWrite". This will let you read
  38. and Write freely in the File, While other processes can freely read the File.
  39. if another process tries to open the File For writing, that process will get
  40. the error "Access denied".
  41.  
  42. (fmNoInherit is seldom used - it defines if a childprocess spawn from your
  43. process will be able to use the Filehandle provided by your process.)
  44.  
  45. The FileMode Variable is only used when the File is opened;
  46.  
  47.  ...
  48. Assign(F,FileName);
  49. FileMode:=fmReadOnly+fmDenyNone;
  50. Reset(F);
  51. FileMode:=<Whatever>    (* Changing FileMode here does not affect the
  52.                            Files already opened *)
  53.  
  54. By default, FileMode is defined as FileMode:=$02 in TP/BP, this is referred
  55. to as "Compatibility mode" in the TP/BP docs. Two processes accessing the
  56. same File With this Filemode results in the critical error "Sharing
  57. violation".
  58. ----------------------------------------------------------------------
  59.